<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javascript">
//初始化表单验证
$("#addForm").validate({ 
	
	
	 rules : {
		 active_title:{
			 required:true,
			 maxlength:20
			 
		 },
		 start : {
				dateISO : true
			},
			 stop : {
					dateISO : true
				},
		},
	messages:{
		active_title: {required: "请输入活动标题"},
		start: {required: "请输入开始时间"},
		stop: {required: "请输入结束时间"}
		
	},
	submitHandler:function(form){
		$(form).ajaxSubmit({
			success:function(data){
				switch (data.flag) {
				case -1:
					Kit.alert("网络繁忙...，请重试");
					return;
				case 1:
					Kit.alert("标题不能为空");
					return;
				case 2:
					Kit.alert("标题长度不能超过20个字");
					return;
				case 3:
					Kit.alert("开始时间不能为空");
					return;
				case 4:
					Kit.alert("结束时间不能为空");
					return;
				case 5:
					Kit.alert("开始时间不能大于结束时间");
				case 0:
					dataPaginator.loadPage(1);
					addDialog.close();
				}
			}
		});
	}
});
/* 验证输入的日期先后顺序 */
$("#startdate").datetimepicker({
	format : 'yyyy-mm-dd',
	language : 'zh-CN',
	weekStart : 1,
	todayBtn : 1,//显示‘今日’按钮
	autoclose : 1,
	todayHighlight : 1,
	startView : 2,
	minView : 2, //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
	forceParse :0,
	endDate:$("#stopdate").val(),
	/* endDate : new Date(), */
}).on('changeDate', function(ev) {
	var starttime = $("#startdate").val();
	$("#stopdate").datetimepicker('setStartDate', starttime);
	$("#startdate").datetimepicker('hide');
});

$("#stopdate").datetimepicker({
	format : 'yyyy-mm-dd',
	language : 'zh-CN',
	weekStart : 1,
	todayBtn : 1,//显示‘今日’按钮
	autoclose : 1,
	todayHighlight : 1,
	startView : 2,
	minView : 2, //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
	forceParse : 0,
	startDate:$("#startdate").val(),
	/*  endDate : new Date(),  */
}).on('changeDate', function(ev) {
	var starttime = $("#startdate").val();
	var endtime = $("#stopdate").val();
	$("#startdate").datetimepicker('setEndDate', endtime);
	$("#stopdate").datetimepicker('hide');
}); 

	
</script>
<form id="addForm" action="${BASE_PATH}/spike/list/doAdd" method="post"
	class="form-horizontal">
	<div class="form-group">
		<label class="col-lg-2 control-label">活动标题</label>
		<div class="col-lg-9">
			<input type="text" name="active_title" value="" class="form-control width130"
				placeholder="请输入活动标题" required maxlength="50">
		</div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">开始时间</label>
		<div class="col-lg-9">
			<input type="text" name="start" id="startdate" placeholder="请输入开始时间" autocomplete="off" value=""
				class="form-control width130 datetimepicker"
				data-format="yyyy-mm-dd" maxLength="20">

		</div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">结束时间</label>
		<div class="col-lg-9">
			<input type="text" name="stop" id="stopdate" placeholder="请输入结束时间" autocomplete="off" value=""
				class="form-control width130 datetimepicker"
				data-format="yyyy-mm-dd" maxlength="20">
		</div>


	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">选取时间时间段</label>
		<div class="col-lg-9">
			<select name="tid" class="selectpicker pull-left" data-isfirst="true" >
				<c:if test="${tl!=null&&fn:length(tl)!=0 }">
					<c:forEach items="${tl}" var="list">
						<option value="${list.id}">${list.time_line}:${list.begin}--${list.end} </option>
					</c:forEach>
				</c:if>
			</select>
		</div>
	</div>
	<div class="form-group">
		<label class="col-lg-2 control-label">是否启用</label>
		<div class="col-lg-9">

			<select name="publish" class="selectpicker form-control">
				<option value="1" selected>上架(默认选中)</option>
				<option value="0">下架</option>
			</select>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-6">
			<button class="btn btn-primary col-sm-3 pull-right" type="submit"
				autocomplete="off">提交</button>
		</div>
		<div class="col-lg-6">
			<button class="btn btn-default col-sm-3 pull-left" type="button"
				onclick="javascript:addDialog.close();" autocomplete="off">取消</button>
		</div>
	</div>
	<%-- <input type="hidden" name="id" value="${object.id}" /> --%>
</form>